package GUILag;

import javax.swing.JPanel;

/**
 * Dette frame bruges til at holde de forskellige paneler.
 * @author DM75 Gruppe 3
 * @version 22-12-2011
 */
public class WorkingPlanGUI extends javax.swing.JFrame {
    private String userLevel;
    private static WorkingPlanGUI _instance = null; // singleton
    
    private WorkingPlanGUI(String userLevel) {
        this.userLevel = userLevel;
        initComp();        
    }
    
    // bliver kaldt fra den klasse som ønsker en instans af dette frame.
    public static WorkingPlanGUI getInstance(String userLev)
    {
        if(_instance == null)
        {
            _instance = new WorkingPlanGUI(userLev);
        }
        return _instance;
    }
        
    /**
     * Slår framet fra således at der ikke kan klikkes i det.
     */
    protected void setWorkingPlanGUIDisabled()
    {
        this.setEnabled(false);
    }
    
    /**
     * Slår framet til således at kan klikkes i det.
     */
    protected void setWorkingPlanGUIEnabled()
    {
        this.setEnabled(true);
        this.requestFocus();
    }
    
    protected void closeFrame()
    {
       this.dispose();
    }
    
    protected void killThis()
    {
        _instance = null; // Bruges for at dræbe framet. (pga. evt skift i userLevel.)
    }
    
    
    // Bruger denne for at kunne lave 4 seperate panels med hver sin location. Kan jeg ikke lave om i det generated code.
    private void initComp()
    {
        jTabbedPane1 = new javax.swing.JTabbedPane();
        JPanel cafePanel1 = new GUILag.WPPanel("Cafe", userLevel, this);
        JPanel receptionPanel1 = new GUILag.WPPanel("Reception", userLevel,this);
        JPanel cafeteria = new GUILag.WPPanel("Cafeteria", userLevel, this);
        JPanel mekanik = new GUILag.WPPanel("Mekaniker", userLevel, this);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Vagtplan");
        setResizable(true);
        setAlwaysOnTop(true);

        jTabbedPane1.addTab("Cafe", cafePanel1);
        jTabbedPane1.addTab("Cafeteria", cafeteria);
        jTabbedPane1.addTab("Mekaniker", mekanik);
        jTabbedPane1.addTab("Reception", receptionPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );

        pack();
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        wPReceptionPanel1 = new GUILag.WPPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Oversigt - Vagtplaner");
        setAlwaysOnTop(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jTabbedPane1.addTab("tab3", wPReceptionPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1260, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 706, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

    }//GEN-LAST:event_formWindowClosing

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane jTabbedPane1;
    private GUILag.WPPanel wPReceptionPanel1;
    // End of variables declaration//GEN-END:variables
}
